/*!
\copyright  Copyright (c) 2023 Qualcomm Technologies International, Ltd.
            All Rights Reserved.
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\file
\brief      Kymera specific implementation of the Mirror profile audio source.

*/

#include "mirror_profile_audio_source.h"
#include "mirror_profile_private.h"
#include <kymera_adaptation_audio_protected.h>
#include <kymera_adaptation.h>

#include <string.h>

void MirrorProfile_RegisterAudioStackAudioInterface(audio_source_t audio_source)
{
    UNUSED(audio_source);
}

void MirrorProfile_StartA2dpAudioSynchronisation(void)
{
#ifdef INCLUDE_MIRRORING
    a2dp_connect_parameters_t params;
    audio_source_t audio_source = MirrorProfile_GetA2dpState()->audio_source;
    connect_parameters_t connect_params =
        {.source = {.type = source_type_audio, .u = {.audio = audio_source}},
         .source_params = {sizeof(params), &params}};

    memset(&params, 0, sizeof(params));
    /* Use any source SEID, to trigger the kymera start forwarding function.
       Leave other fields as zero as they are not used in this mode */
    params.seid = AV_SEID_SBC_MONO_TWS_SRC;
    params.sink = MirrorProfile_GetA2dpAudioSyncTransportSink();
    params.client_lock = MirrorProfile_GetA2dpStartLockAddr();
    params.client_lock_mask = MIRROR_PROFILE_AUDIO_START_LOCK;

    KymeraAdaptation_Connect(&connect_params);
#endif
}

void MirrorProfile_StopA2dpAudioSynchronisation(void)
{
#ifdef INCLUDE_MIRRORING
    a2dp_disconnect_parameters_t params;
    audio_source_t audio_source = MirrorProfile_GetA2dpState()->audio_source;
    disconnect_parameters_t disconnect_params = {
        .source = {.type = source_type_audio, .u = {.audio = audio_source}},
        .source_params = {sizeof(params), &params}};

    memset(&params, 0, sizeof(params));
    /* Use any source SEID, to trigger the kymera start forwarding function.
       Leave other fields as zero as they are not used in this mode */
    params.seid = AV_SEID_SBC_MONO_TWS_SRC;
    params.source = MirrorProfile_GetA2dpAudioSyncTransportSource();

    KymeraAdaptation_Disconnect(&disconnect_params);
#endif
}
